﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TournamentDatabase.Database;

namespace TournamentDatabase.Objects
{
	public class Tournament
	{
		private int m_tid;
		private string m_title;
		private string m_address;
		private DateTime m_startDate;
		private DateTime m_endDate;

		public int TournamentID
		{
			get { return m_tid; }
			set { m_tid = value; }
		}
		public string Title
		{
			get { return m_title; }
			set { m_title = value; }
		}
		public string Address
		{
			get { return m_address; }
			set { m_address = value; }
		}
		public DateTime StartDate
		{
			get { return m_startDate; }
			set { m_startDate = value; }
		}
		public DateTime EndDate
		{
			get { return m_endDate; }
			set { m_endDate = value; }
		}

		public Tournament() : this(0, "", "", DateTime.Today, DateTime.Today) { }
		public Tournament(int tid, string title, string address, DateTime startDate, DateTime endDate)
		{
			m_tid = tid;
			m_title = title;
			m_address = address;
			m_startDate = startDate;
			m_endDate = endDate;
		}
		public Tournament(OracleDataReader odr)
		{
			TournamentID = int.Parse(odr["tid"]);
			EndDate = DateTime.Parse(odr["startDate"]);
			StartDate = DateTime.Parse(odr["endDate"]);
			Title = odr["title"].ToString();
			Address = odr["address"].ToString();
		}

		public static List<Tournament> ParseTournament(OracleDataReader odr)
		{
			List<Tournament> list = new List<Tournament>();
			while (odr.Read())
			{
				list.Add(new Tournament());
			}
			return list;
		}
	}
}
